//
//  MHCacheDiskHelper.m
//  cacheTool
//
//  Created by 牟华 on 16/10/31.
//  Copyright © 2016年 牟华. All rights reserved.
//

#import "MHCacheDiskHelper.h"


@implementation MHCacheDiskHelper

- (void(^)(NSString *key, id value, saveCompleteHandler saveComplete))saveObject
{
    return ^(NSString *key, id value, saveCompleteHandler saveComplete){
        [[MHDiskCacheTool sharedCacheObj] cacheWithKey:key value:value image:nil data:nil completeHandler:saveComplete];
    };
    
}

- (void(^)(NSString *key, UIImage *image, saveCompleteHandler saveComplete))saveImage
{
    return ^(NSString *key, UIImage *image, saveCompleteHandler saveComplete){
        [[MHDiskCacheTool sharedCacheImage] cacheWithKey:key value:nil image:image data:nil completeHandler:saveComplete];
    };
}

- (void(^)(NSString *key, NSData *otherData, saveCompleteHandler saveComplete))saveOtherData
{
    return ^(NSString *key, NSData *otherData, saveCompleteHandler saveComplete){
        [[MHDiskCacheTool sharedCacheOtherData] cacheWithKey:key value:nil image:nil data:otherData completeHandler:saveComplete];
    };
}

- (void(^)(NSString *key, void(^completeObj)(id value)))getObject
{
    return ^(NSString *key, void(^completeObj)(id value)){
        [[MHDiskCacheTool sharedCacheObj] getWithKey:key objectGetHandler:completeObj imageGetHandler:nil otherDataGetHandler:nil];
    };
}

- (void(^)(NSString *key, void(^completeImage)(UIImage *image)))getImage
{
    return ^(NSString *key, void(^completeImage)(UIImage *image)){
        [[MHDiskCacheTool sharedCacheImage] getWithKey:key objectGetHandler:nil imageGetHandler:completeImage otherDataGetHandler:nil];
    };
}

- (void(^)(NSString *key, void(^completeOtherData)(NSData *data)))getOtherData
{
    return ^(NSString *key, void(^completeOtherData)(NSData *data)){
        [[MHDiskCacheTool sharedCacheOtherData] getWithKey:key objectGetHandler:nil imageGetHandler:nil otherDataGetHandler:completeOtherData];
    };
}

- (void(^)())clearDiskCache
{
    return ^{
        [MHDiskCacheTool clearDisk];
    };
}

@end
